<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateCoupons extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('coupons', function (Blueprint $table) {
            $table->id();
            $table->timestamps();
            $table->date("end_date")->comment("截止日期");
            $table->string("title")->comment("券的标题");
            $table->string("descript")->nullable()->comment("券的描述");
            $table->integer("type")->index()->comment("券的类型、性质");
            $table->boolean("is_used")->index()->default(0)->comment("是否使用");
            $table->date("used_date")->nullable()->comment("啥时候用的这个券");
            $table->foreignId("user_id")->constrained()->onDelete('cascade')->comment("劵的拥有者");

        });
    }

    /**
     * Reverse the migrations.
     * 
     * @return void
     */
    public function down()
    {
        Schema::dropForeign(['user_id']);
        Schema::dropIfExists('coupons');
    }
}
